<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>GT pro钱包</title>
		<!-- Tell the browser to be responsive to screen width -->
		<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
		<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
		<link rel="stylesheet" href="bower_components/Ionicons/css/ionicons.min.css">
		<link rel="stylesheet" href="bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
		<link rel="stylesheet" href="dist/css/AdminLTE.min.css">
		<link rel="stylesheet" href="dist/css/skins/skin-blue.min.css">
		<link rel="stylesheet" href="css/style.css">
		<link rel="stylesheet" href="css/fr_style.css">
		<link rel="stylesheet" href="css/card.css">
		<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">

		<link rel="stylesheet" href="bower_components/bootstrap-daterangepicker/daterangepicker.css">
		<link rel="stylesheet" href="bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
		<script type="text/javascript" src="./libs/spark-md5-3.0.0.min.js"></script>
		<script type="text/javascript" src="./libs/crypto-js.js"></script>
		<script type="text/javascript" src="./libs/base64.min.js"></script>
		<script type="text/javascript" src="./libs/ufile-token.js"></script>
	</head>
	</head>
	<style type="text/css">
		textarea {
			width: 100%;
			border: 1px solid #ddd;
			line-height: 24px;
			padding: 5px 10px;
			height: 350px;
		}
		
		#localImgBtn+.ke-upload-button {
			display: none;
		}
	</style>

	<body class="hold-transition skin-blue sidebar-mini">
		<div class="wrapper">
			<div class="content-wrapper">
				<section class="content">
					<div class="buyu_search_group">
						
						<div class="row box" style="margin: 0;">
							<div class="box-header with-border">
								投资产品
							</div>
							
							<div class="col-sm-3" style="margin: 10px 0;padding: 0;">
								<label class="margin-bottom-none col-xs-12" style="font-weight: normal;line-height: 2;min-width: 200px;">标题：
									<input type="text" class="form-control" id="title" name="title"/>
								</label>
							</div>
							<div class="col-sm-3" style="margin: 10px 0;padding: 0;">
								<label class="margin-bottom-none col-xs-12" style="font-weight: normal;line-height: 2;min-width: 200px;">产品名称：
									<input type="text" class="form-control" id="name" name="name"/>
								</label>
							</div>
							<div class="col-sm-3" style="margin: 10px 0;padding: 0;">
								<label class="margin-bottom-none col-xs-12" style="font-weight: normal;line-height: 2;min-width: 200px;">标签：
									<input type="text" class="form-control" id="tag" name="tag"/>
								</label>
							</div>
							<div class="col-sm-3" style="margin: 10px 0;padding: 0;">
								<label class="margin-bottom-none col-xs-12" style="font-weight: normal;line-height: 2;min-width: 200px;">备注：
									<input type="text" class="form-control" id="remark" name="remark"/>
								</label>
							</div>
							<div class="col-sm-3" style="margin: 10px 0;padding: 0;">
								<label class="margin-bottom-none col-xs-12" style="font-weight: normal;line-height: 2;min-width: 200px;">时长（天）：
									<input type="text" class="form-control" id="duration" name="duration"/>
								</label>
							</div>
							<div class="col-sm-3" style="margin: 10px 0;padding: 0;">
								<label class="margin-bottom-none col-xs-12" style="font-weight: normal;line-height: 2;min-width: 200px;">参与总数：
									<input type="text" class="form-control" id="max_num" name="max_num"/>
								</label>
							</div>
							<div class="col-sm-3" style="margin: 10px 0;padding: 0;">
								<label class="margin-bottom-none col-xs-12" style="font-weight: normal;line-height: 2;min-width: 200px;">最小参与数量：
									<input type="text" class="form-control" id="min_join_num" name="min_join_num"/>
								</label>
							</div>
							<div class="col-sm-3" style="margin: 10px 0;padding: 0;">
								<label class="margin-bottom-none col-xs-12" style="font-weight: normal;line-height: 2;min-width: 200px;">单用户最多参与数量：
									<input type="text" class="form-control" id="user_max_num" name="user_max_num"/>
								</label>
							</div>
							<div class="col-sm-3" style="margin: 10px 0;padding: 0;">
								<label class="margin-bottom-none col-xs-12" style="font-weight: normal;line-height: 2;min-width: 200px;">收益百分比：
									<input type="text" class="form-control" id="income_rate" name="income_rate"/>
								</label>
							</div>
							<div class="col-sm-3" style="margin: 10px 0;padding: 0;">
								<label class="margin-bottom-none col-xs-12" style="font-weight: normal;line-height: 2;min-width: 200px;">结束时间：
									<input type="text" class="form-control" id="end_time" name="end_time"/>
								</label>
							</div>
							<div class="col-sm-3" style="margin: 10px 0;padding: 0;">
								<label class="margin-bottom-none col-xs-12" style="font-weight: normal;line-height: 2;min-width: 200px;">参与币种：
								<select type="text" class="form-control coin_list" name="join_coin_id"></select>
							</label>
							</div>
							<div class="col-sm-3" style="margin: 10px 0;padding: 0;">
								<label class="margin-bottom-none col-xs-12" style="font-weight: normal;line-height: 2;min-width: 200px;">收益币种：
								<select type="text" class="form-control coin_list" name="income_coin_id"></select>
							</label>
							</div>
							<div class="col-sm-3" style="margin: 10px 0;padding: 0;">
								<label class="margin-bottom-none col-xs-12" style="font-weight: normal;line-height: 2;min-width: 200px;">状态：
								<select type="text" class="form-control coin_list" name="status">
									<option value="0">进行中</option>
									<option value="3">即将上线</option>
								</select>
							</label>
							</div>

							<div class="col-sm-12"  id="rule_div">
								<div style="font-weight: normal;line-height: 2;min-width: 200px;">规则</div>
								<textarea id="rule" name="rule" class="editor"></textarea>
							</div>
							<div class="col-sm-12" id="intro_div">
								<div style="font-weight: normal;line-height: 2;min-width: 200px;">项目说明</div>
								<textarea id="intro" name="intro" class="editor"></textarea>
							</div>
							<div class="col-sm-12" style="margin: 10px 0">
								<button class="btn bg-orange margin-r-5" id="save" onclick="operation()">保存</button>
							</div>
						</div>
				</section>
				<!-- /.content -->
				</div>
			</div>
			<!-- ./wrapper -->

			<!-- jQuery 3 -->
			<script src="bower_components/jquery/dist/jquery.min.js"></script>
		<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
		<script src="bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
		<script src="bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>

		<script src="bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
		<script src="bower_components/moment/min/moment.min.js"></script>
		<script src="bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>
			<script charset="utf-8" src="kindeditor/kindeditor-all.js"></script>
			<script charset="utf-8" src="kindeditor/lang/zh-CN.js"></script>
			<script src="js/argument.js"></script>
			<script src="js/fun.js"></script>
			<script src="js/nav.js"></script>
			<script src="js/pop.js"></script>

			<script type="text/javascript">
				$(".sidebar a[href='notice_list.html']").parent().addClass('active')
				$(".sidebar a[href='notice_list.html']").parent().parent().parent().addClass('active')
				function error(res) {
					alert('接口报错')
					console.log(res)
					$("#loading").hide()
				}
				$.ajax({
					type: 'post',
					url: url + "Back_MainChainForCoin",
					contentType: "application/x-www-form-urlencoded",
					headers: {
						"auth-token": localStorage.getItem("wallet_token")
					},
					data: {
						data: JSON.stringify({
							page_num: 1
						})
					},
					dataType: 'json',
					success: function(res) {
						console.log(res);
						if(res.status == 1000||res.status == 102) {
							ToLogin(res)
							return false;
						} else if(res.status != 1) {
							alert(res.error);
							return false;
						}
						var id;
						$.each(res.data, function(index, item) {
							$(".coin_list").append('<option value='+item.id+'>'+item.name+'</option>');
						})
					}
				})
			
				$('#end_time').datepicker({
					autoclose: true,
					format: 'yyyy-mm-dd',
				})
				KindEditor.ready(function(K) {
					var options = {
						filterMode: true
					}
					window.editor_rule = K.create('textarea[name="rule"]', options);
				});
				KindEditor.ready(function(K) {
					//初始化编辑器
					var options = {
						filterMode: true
					}
					window.editor_intro = K.create('textarea[name="intro"]', options);
				});
				
				function product(address) {
					var list = ['title', 'name', 'tag', 'remark', 'duration', 'max_num', 'min_join_num', 'income_rate', 'user_max_num', 'join_coin_id', 'income_coin_id', 'status','end_time'];
					var data = {};
					$.each(list, function(index, item) {
						data[item] = $("#" + item).val()
					})
					
					data.rule  = $("#rule_div").find('.ke-edit-iframe').contents().find("body").html()
					data.intro  = $("#intro_div").find('.ke-edit-iframe').contents().find("body").html()
					console.log(data);
					return false;
					$.ajax({
						type: 'post',
						url: url + address,
						"headers": {
							"auth-token": localStorage.getItem("wallet_token")
						},
						"contentType": "application/json",
						data: JSON.stringify(data),
						success: function(res) {
							if(res.status == 1000||res.status == 102) {
								ToLogin(res)
								return false;
							} else if(res.status != 1) {
								alert(res.error);
								return false;
							}
							alert("操作成功！")
							window.location.href = 'product_list.html';
						}
					})
				}
				
				
				function operation() {
					if(GetRequest().id){
						product('Back_ProductUpdate');
					}else{
						product('Back_ProductAdd');
					}
				}
			</script>
	</body>

</html>